home *** CD-ROM | disk | FTP | other *** search
- Path: fido.asd.sgi.com!austern
- From: thp@cs.ucr.edu (Tom Payne)
- Newsgroups: comp.std.c++
- Subject: Re: Referencing pointers after delete
- Date: 08 Apr 1996 10:15:58 PDT
- Organization: University of California, Riverside
- Approved: austern@isolde.mti.sgi.com
- Message-ID: <4ka03d$228@galaxy.ucr.edu>
- References: <m0u4G70-000GcEC@7.kurahaupo.gen.nz>
- NNTP-Posting-Host: isolde.mti.sgi.com
- X-Original-Date: 8 Apr 1996 03:10:37 GMT
- X-Newsreader: TIN [UNIX 1.3 950824BETA PL0]
- X-Auth: PGPMoose V1.1 PGP comp.std.c++
- iQBVAwUBMWlJz0y4NqrwXLNJAQHw/gH/WOEyvwkrwqBJyd0sBdPnfAKwRnUWi0nT
- kndJ2ZWaDupH4hc0EfnX0QU+xfPOc7L5/2/5VMc7PGYjbjEt/JhJPw==
- =phvq
- Originator: austern@isolde.mti.sgi.com
-
- Martin D Kealey (martin@kcbbs.gen.nz) wrote:
- [...]
- : *Sigh* This is not supposed to be a complete description, just an
- : example. So ok, change it to invalidate all registers which
- : contain pointers to the same type as p, not just the single
- : register which contains the value of p. Also, *all* registers are
- : invalidated over (non-inline) function calls, or any other time
- : we're not 100% sure what they might contain.
- :
- : I think now that accidental use of register aliasing is not
- : possible -- one has explicitly to use p (or an alias for it) as a
- : non-lvalue in the source code to cause this effect, and that means
- : the program is non-conforming.
-
- Agreed. With a sufficiently conservative invalidation policy, the
- implementation conforms. So, would it continue to conform if a valid
- program could read an invalid pointer (a pointer object at a time when
- it happens to hold an invalid value)? I think so. The implementation
- can freely assume that a pointer object holds a valid value from the
- time it is assigned that value until it is invalidated, since, if the
- assigned value was invalid, then the implementation is off the hook
- via "undefined behavior." It would make no difference whether that
- invalid value was generated by reading a pointer to a deleted object
- or though assigning the presumably invalid value (int*)1.
-
- : I know this is a perverse implementation that does some pretty
- : fantastic peephole optimising without bothering to do any dataflow
- : analysis, but that alone doesn't currently make it non-conforming.
-
- Right! Besides, it shows that one could possibly lose opportunities
- for optimization if it were permitted to assign invalid values to
- a pointer object.
-
- Tom Payne (thp@cs.ucr.edu)
- ---
- [ comp.std.c++ is moderated. To submit articles: Try just posting with your
- newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
- comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
- Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
- Comments? mailto:std-c++-request@ncar.ucar.edu
- ]
-